#ifndef _OGREWIDGET_H_
#define _OGRE_WIDGET_H_
#include <QtGui\QWidget>
#include "OgreApplication.h"


// override is a Visual Studio 2005 and later keyword.  If not using the Visual
// Studio compiler, define override as nothing
#if !defined(_MSC_VER)
#define override
#endif


class OgreWidget : public QWidget, public OgreApplication
{
  Q_OBJECT

public:
  OgreWidget(QWidget* parent = 0);
  ~OgreWidget(void);

  virtual bool setup(void) override;

signals:
  // Emitted when Ogre has successfully been setup
  void setupComplete(void);

protected:
  // Return NULL for the painEngine so that Ogre can paint to the widget 
  // exclusively.
  virtual QPaintEngine* paintEngine(void) const {return NULL;}

  virtual void mousePressEvent(QMouseEvent*);
  virtual void mouseMoveEvent(QMouseEvent*);
  virtual void mouseReleaseEvent(QMouseEvent*);
  virtual void keyPressEvent(QKeyEvent*);
  virtual void keyReleaseEvent(QKeyEvent*);

  // Every time timerEvent() is called, another frame will render
  virtual void timerEvent(QTimerEvent*);
  virtual void resizeEvent(QResizeEvent*);
  virtual void update(float timeSinceLastUpdate) override;

  virtual bool configure(void) override;
  
  void setCameraSpeed(float speed) {mMoveSpeed = speed;}
  void moveCamera(const Ogre::Vector3& translate);
  void rotateCamera(float rx, float ry, float rz);

protected:
  QPoint mLastMousePos;
  Ogre::Vector3 mTranslateVec;
  Ogre::Degree mRotX;
  Ogre::Degree mRotY;
  float mMoveSpeed;
};

#endif // _OGRE_WIDGET_H_